package eafit.sicom.mpark;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.app.Activity;
import android.content.res.Resources;

/**
 * Manages connection with REST Services
 * @author SICOM
 *
 */
public class WebManager {
	
	/**
	 * Gets list of Parking and this information
	 * @return XML information
	 * @throws IllegalStateException
	 * @throws IOException
	 */
	public static String getXmlParking() throws IllegalStateException, IOException {
		String xmlString = "";
		//Realiza la conexion al Rest Services
		HttpClient client = new DefaultHttpClient();
		HttpGet request = new HttpGet("http://dis.eafit.edu.co/sicom/parking.php");
		HttpResponse response = client.execute(request);
		//Toma el Stream de datos y o pone en un String
		BufferedReader rd = new BufferedReader(new InputStreamReader(response
				.getEntity().getContent()));
		String line = "";
		while ((line = rd.readLine()) != null) {
			xmlString = xmlString + line;
		}
		return xmlString;
	}
}
